News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.newscategorycourseinvite.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
3.28 %3.28%
3.28% 2 / 61
 
NewsCategoryCourseInvite
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 6
1.67 %1.67%
1.67% 1 / 60
 public function __construct($catID, $courses, $userID, $categorySettings = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 20
 public function isInstalled($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function canSelectPeriod()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getNewsHeaderTitle($courseID = NULL, $type = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 protected function echoNewsEntry($entry, $courseID, $usergroup = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 17


       1                 : <?php                                                                                                                                                                       
       2                 : /*--------------------------------------------------------------------------+                                                                                               
       3                 :  This file is part of eStudy.                                                                                                                                               
       4                 :  news/classes/class.NewsCategoryCourses.inc.php                                                                                                                             
       5                 :  - Modulgruppe:  News                                                                                                                                                       
       6                 :  - Beschreibung: Klasse fuer die News-Kategorie Kurs Einladungen.                                                                                                           
       7                 :  - Version:      0,17/11/08                                                                                                                                                 
       8                 :  - Autor(en):    Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                            
       9                 :  +---------------------------------------------------------------------------+                                                                                              
      10                 :  This program is free software; you can redistribute it and/or                                                                                                              
      11                 :  modify it under the terms of the GNU General Public License                                                                                                                
      12                 :  as published by the Free Software Foundation; either version 2                                                                                                             
      13                 :  of the License, or any later version.                                                                                                                                      
      14                 :  +---------------------------------------------------------------------------+                                                                                              
      15                 :  This program is distributed in the hope that it will be useful,                                                                                                            
      16                 :  but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                             
      17                 :  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                              
      18                 :  GNU General Public License for more details.                                                                                                                               
      19                 :  You should have received a copy of the GNU General Public License                                                                                                          
      20                 :  along with this program; if not, write to the Free Software                                                                                                                
      21                 :  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                
      22                 :  +--------------------------------------------------------------------------*/                                                                                              
      23                 :                                                                                                                                                                             
      24               1 : require_once ("class.newscategory.inc.php");                                                                                                                                
      25                 :                                                                                                                                                                             
      26                 : /**                                                                                                                                                                         
      27                 :  * Klasse f�r die News-Kategorie Kurs-Einladungen.                                                                                                                        
      28                 :  * @package eStudy.News                                                                                                                                                     
      29                 :  * @version 0,17/11/08                                                                                                                                                      
      30                 :  * @author  Corinna Kropf <corinna.kropf@mni.fh-giessen.de>                                                                                                                 
      31                 :  */                                                                                                                                                                         
      32               1 : class NewsCategoryCourseInvite extends NewsCategory                                                                                                                         
      33                 : {                                                                                                                                                                           
      34                 :     /**                                                                                                                                                                     
      35                 :      * HTML-Template                                                                                                                                                        
      36                 :      * @var Template                                                                                                                                                        
      37                 :      */                                                                                                                                                                     
      38                 :     private $newsTemplate;                                                                                                                                                  
      39                 :     /**                                                                                                                                                                     
      40                 :      * @var int                                                                                                                                                             
      41                 :      */                                                                                                                                                                     
      42                 :     private $userID;                                                                                                                                                        
      43                 :                                                                                                                                                                             
      44                 :     /**                                                                                                                                                                     
      45                 :      * Konstruktor                                                                                                                                                          
      46                 :      * @param $userID int                                                                                                                                                   
      47                 :      */                                                                                                                                                                     
      48                 :     public function __construct($catID, $courses, $userID, $categorySettings = null)    {                                                                                   
      49               0 :         parent::__construct($catID, $courses, $categorySettings);                                                                                                           
      50               0 :         $this->userID = $userID;                                                                                                                                            
      51               0 :         if (!isset($this->newsTemplate))                                                                                                                                    
      52               0 :             $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newscourse.html");                                                                              
      53               0 :         if (isset($_POST)) {                                                                                                                                                
      54               0 :             if (isset($_POST["apply_Invite"])) {                                                                                                                            
      55               0 :                 if(!Course::addParticipant($_POST["userID_Invite"],$_POST["courseID_Invite"], $_POST["differentUsergroup_Invite"]))                                         
      56               0 :                 {                                                                                                                                                           
      57               0 :                     Output::errorMessage("Benutzer konnte nicht hinzugef&uuml;gt werden, da er schon in dem Kurs vorhanden ist.");                                          
      58               0 :                 }                                                                                                                                                           
      59               0 :                 global $db;                                                                                                                                                 
      60                 :                 $sql =   "DELETE FROM user_course_request "                                                                                                                 
      61               0 :                 ."WHERE userID = ".$_POST["userID_Invite"]." and courseID = ".$_POST["courseID_Invite"]." and differentUsergroup = ".$_POST["differentUsergroup_Invite"]."";
      62               0 :                 $this->news["data"] = $db->get_results($sql, ARRAY_A);                                                                                                      
      63               0 :             } else if (isset($_POST["reject_Invite"])) {                                                                                                                    
      64               0 :                 global $db;                                                                                                                                                 
      65                 :                 $sql =   "DELETE FROM user_course_request "                                                                                                                 
      66               0 :                 ."WHERE userID = ".$_POST["userID_Invite"]." and courseID = ".$_POST["courseID_Invite"]." and differentUsergroup = ".$_POST["differentUsergroup_Invite"]."";
      67               0 :                 $this->news["data"] = $db->get_results($sql, ARRAY_A);                                                                                                      
      68               0 :             }                                                                                                                                                               
      69               0 :         }                                                                                                                                                                   
      70               0 :     }                                                                                                                                                                       
      71                 :                                                                                                                                                                             
      72                 :     /**                                                                                                                                                                     
      73                 :      * @see NewsCategory                                                                                                                                                    
      74                 :      */                                                                                                                                                                     
      75                 :     public function isInstalled($courseID)    {                                                                                                                             
      76               0 :         return (($courseID == 0)? true : false);                                                                                                                            
      77                 :     }                                                                                                                                                                       
      78                 :     /**                                                                                                                                                                     
      79                 :      * @see NewsCategory                                                                                                                                                    
      80                 :      */                                                                                                                                                                     
      81                 :     public function canSelectPeriod() {                                                                                                                                     
      82               0 :         return false;                                                                                                                                                       
      83                 :     }                                                                                                                                                                       
      84                 :                                                                                                                                                                             
      85                 :     /**                                                                                                                                                                     
      86                 :      * @see NewsCategory                                                                                                                                                    
      87                 :      */                                                                                                                                                                     
      88                 :     public function getNewsHeaderTitle($courseID = null, $type = null) {                                                                                                    
      89               0 :         if(isset($this->news))                                                                                                                                              
      90               0 :         {                                                                                                                                                                   
      91               0 :             $newsCount = $this->news["count"];                                                                                                                              
      92               0 :             if ($newsCount > 1) $title = "$newsCount Kurs Einladungen";                                                                                                     
      93               0 :             elseif ($newsCount == 1) $title = "Eine Kurs Einladung";                                                                                                        
      94               0 :         }                                                                                                                                                                   
      95               0 :         else $title = "Keine neuen Kurs Einladungen";                                                                                                                       
      96                 :                                                                                                                                                                             
      97               0 :         return $title;                                                                                                                                                      
      98                 :     }                                                                                                                                                                       
      99                 :     /**                                                                                                                                                                     
     100                 :      * @see NewsCategory                                                                                                                                                    
     101                 :      */                                                                                                                                                                     
     102                 :     protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null)  {                                                                             
     103               0 :         global $db;                                                                                                                                                         
     104               0 :         $this->news = array();                                                                                                                                              
     105               0 :         $userid = Data::toMysql($this->userID);                                                                                                                             
     106                 :                                                                                                                                                                             
     107               0 :         if (!$courseID) {                                                                                                                                                   
     108                 :             $sql =   "SELECT * FROM user_course_request,courses "                                                                                                           
     109               0 :             ."WHERE userID = '$userid' AND user_course_request.courseID = courses.ID";                                                                                      
     110               0 :             $this->news["data"] = $db->get_results($sql, ARRAY_A);                                                                                                          
     111               0 :             if ($db->num_rows == 0){                                                                                                                                        
     112               0 :                 $this->news = null;                                                                                                                                         
     113               0 :             } else {                                                                                                                                                        
     114               0 :                 $this->news["count"] = $db->num_rows;                                                                                                                       
     115                 :             }                                                                                                                                                               
     116               0 :         }                                                                                                                                                                   
     117               0 :         return $this->news;                                                                                                                                                 
     118                 :     }                                                                                                                                                                       
     119                 :     /**                                                                                                                                                                     
     120                 :      * @see NewsCategory                                                                                                                                                    
     121                 :      */                                                                                                                                                                     
     122                 :     protected function echoNewsEntry($entry, $courseID, $usergroup = null)    {                                                                                             
     123               0 :         $g_ZurKursInfo = "Zur Kursinformation";                                                                                                                             
     124               0 :         $g_Lesen = "Lesen";                                                                                                                                                 
     125               0 :         $closed = "";                                                                                                                                                       
     126               0 :         $courseName = Data::toHTML("$entry[Name] ($entry[ShortName])", false);                                                                                              
     127               0 :         $profileLink = "";                                                                                                                                                  
     128               0 :         $courseInfo = Utilities::chopText($entry["Info"], 150);                                                                                                             
     129                 :                                                                                                                                                                             
     130                 :         $courseInfo .=                                                                                                                                                      
     131               0 :         "<form action=\"".PATH_TO_ROOT.SCRIPT_NAME."\" method=\"post\">"                                                                                                    
     132               0 :         ."<input type='hidden' name='userID_Invite' value='".Data::toHTML($entry["userID"])."'/>"                                                                           
     133               0 :         ."<input type='hidden' name='courseID_Invite' value='".Data::toHTML($entry["courseID"])."'/>"                                                                       
     134               0 :         ."<input type='hidden' name='differentUsergroup_Invite' value='".Data::toHTML($entry["differentUsergroup"])."'/>"                                                   
     135               0 :         ."<input type='submit' name= 'apply_Invite' value='Annehmen' />"                                                                                                    
     136               0 :         ."<input type='submit' name= 'reject_Invite' value='Ablehnen' />"                                                                                                   
     137               0 :         ."</form>";                                                                                                                                                         
     138                 :                                                                                                                                                                             
     139               0 :         $scriptPath = PATH_TO_ROOT."courses/courseinfo.php";                                                                                                                
     140               0 :         $courseID = Data::toHTML($entry["ID"], false);                                                                                                                      
     141               0 :         eval($this->newsTemplate->GetTemplate());                                                                                                                           
     142               0 :     }                                                                                                                                                                       
     143                 : }                                                                                                                                                                           

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.